<html>
	<head>
		<meta charset="UTF-8">
		Netty WebSocket 时间服务器
		<script type="text/javascript">
			var socket;
			if(!window.WebSocket){
				window.WebSocket= window.MozWebSocket;
			}
			if(window.WebSocket){
				socket= new WebSocket("ws://localhost:8080/websocket");
				socket.onmessage= function(event){
					addli(event.data);
				};
				socket.onopen= function(event){
					var ta= document.getElementById("responseText");
					ta.value= "connect websocket success";
				};
				socket.onclose= function(event){
					var ta= document.getElementById("responseText");
					ta.value= "";
					ta.value= "websocket has been closed.";
				};
			}else{
				alert("your browser can not support websocket");
			}
			
			function send(message){
				if(!window.WebSocket){return;}
				if(socket.readyState == WebSocket.OPEN){
					socket.send(message);
				}else{
					alert("websocket can not connect.");
				}
			}
			
		 function addli(ab){
			var ul=document.getElementById("responseText");             
			var obj=document.createElement("li");         
			obj.innerHTML=ab;           
			ul.appendChild(obj);                
		}
		</script>
	</head>
	<br>
	<body>
		<br>
		<form onsubmit="return false;">
			<input type="text" name="message" value="hello netty websocket"></input>
			<br><br>
			<input type="button" value="send websocket message" onclick="send(this.form.message.value)"/>
			<hr color="blue"/>
			<h3>WebServer Response message</h3>
			<ul id="responseText" style="width:700px;height:300px;">
			</ul>
		</form>
	</body>
</html>